using System;
using System.Data;
using System.Configuration;

/// <summary>
/// Summary description for FarmApplicationState
/// </summary>
namespace AspWebUtilities.Farm
{
	public partial class FarmApplicationState
	{

		public FarmApplicationState()
		{

		}

		public void Remove(String DataName)
		{
			FarmData.Remove(DataName);
		}

		public Boolean LockForServer(String DataName)
		{
			FarmData vv = (FarmData)Datas[DataName];
			if (vv != null)
			{
				return vv.LockForServer();
			}
			else
			{
				vv = new FarmData(DataName);
				if(vv.Value != null)
				{
					vv.LockForServer();
					Datas.Add(DataName, vv);
					return true;
				}
			}
			return false;
		}

		public Boolean UnlockForServer(string DataName)
		{
			FarmData vv = (FarmData)Datas[DataName];
			if (vv != null)
			{
				return vv.UnlockForServer();
			}
			else
			{
				vv = new FarmData(DataName);
				if (vv.Value != null)
				{
					vv.UnlockForServer();
					Datas.Add(DataName, vv);
					return true;
				}
			}
			return false;
		}
		
		public void UnLockAll()
		{
			FarmData.UnLockAll();
		}

		public void UnLockAllOwne()
		{
			FarmData.UnLockAllOwne();
		}

		public Boolean IsLockedByServer(string DataName)
		{
			FarmData vv = (FarmData)Datas[DataName];
			if (vv != null)
			{
				return vv.LockedByServer;
			}
			else
			{
				vv = new FarmData(DataName);
				if (vv.Value != null)
				{
					Datas.Add(DataName, vv);
					return vv.LockedByServer;
				}
			}
			return false;
		}
	}
}